﻿namespace Deppton.Model
{
    using System;
    using System.Collections.Generic;

    public class AndCondition : Condition
    {
        public AndCondition()
        {
            this.Conditions = new List<Condition>();
        }

        public List<Condition> Conditions
        {
            get;
            protected set;
        }

        public override bool Evaluate(Func<string, string> valueResolver, Func<string, NamedList<KeyValuePair<string, string>>> metadataResolver)
        {
            foreach (var condition in this.Conditions)
            {
                if (!condition.Evaluate(valueResolver, metadataResolver))
                {
                    return false;
                }
            }

            return true;
        }
    }
}
